package net.wofly.finance.expense.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import net.wofly.common.persistence.BaseRepository;
import net.wofly.finance.expense.domain.ExpenseAccount;

public interface ExpenseAccountRepository extends BaseRepository<ExpenseAccount,String> {
	
	@Query(value = "SELECT CAST(SUBSTRING(expenseAccountNO, 9) as UNSIGNED INTEGER) FROM sale_finance_expense WHERE expenseAccountNO " +
			"LIKE :expenseAccountNO ORDER BY CAST(expenseAccountNO as UNSIGNED INTEGER) DESC LIMIT 0, 1", nativeQuery = true)
	public Long findLastExpenseAccountNOForEveryday(@Param("expenseAccountNO") String expenseAccountNO) ;
	
	
	public List<ExpenseAccount> findByProcessInsIDIn(List<String> processInsIDs) ;
	
	public ExpenseAccount findByProcessInsID(String processInsId) ;

}
